import request from '@/utils/request'
import qs from 'qs'
// 查询套餐记录列表
export function listAudit(query) {
  return request({
    url: '/workflow/audit/list',
    method: 'get',
    params: query
  })
}

// 查询套餐记录详细
export function getAudit(id) {
  return request({
    url: '/workflow/audit/' + id,
    method: 'get'
  })
}

// 新增套餐记录
export function addAudit(data) {
  return request({
    url: '/workflow/audit',
    method: 'post',
    data: data
  })
}
// 发起审核
export function startAudit(serviceItemId,info) {
  let params = {serviceItemId,info}
  let formParams = qs.stringify({serviceItemId,info},{indices:false})
  return request({
    url: '/workflow/audit/audit',
    method: 'post',
    data:formParams,
    headers:{'content-type':'application/x-www-form-urlencoded'}
  })
}
// 发起审核
export function cancel(id,reason) {
  let params = {id,reason}
  let formParams = qs.stringify({id,reason},{indices:false})
  return request({
    url: '/workflow/audit/cancel',
    method: 'post',
    data:formParams,
    headers:{'content-type':'application/x-www-form-urlencoded'}
  })
}
// 查看流程进度
export function getProcessingImage(instanceId) {
  return request({
    url: '/workflow/audit/processing/image',
    method: 'get',
    params: {instanceId}
  })
}
// 修改套餐记录
export function updateAudit(data) {
  return request({
    url: '/workflow/audit',
    method: 'put',
    data: data
  })
}

// 删除套餐记录
export function delAudit(id) {
  return request({
    url: '/workflow/audit/' + id,
    method: 'delete'
  })
}
// 审批功能
export function doAudit(params) {
  let formParams = qs.stringify(params, {indices: false});

  return request({
    url: '/workflow/audit/doAudit',
    data: formParams,
    headers: {'content-type': 'application/x-www-form-urlencoded'}, // 表单参数
    method: 'post'
  })
}
// 重新审核
export function reapply(params) {
  let formParams = qs.stringify(params,{indices:false})
  return request({
    url: '/workflow/audit/reapply',
    method: 'post',
    data:formParams,
    headers:{'content-type':'application/x-www-form-urlencoded'}
  })
}
